package com.goods.controller.business;

import com.goods.business.service.OutStockService;
import com.goods.common.model.business.OutStock;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.OutStockVO;
import com.goods.common.vo.system.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 发放记录页面
 */
@RestController
@RequestMapping("/business/outStock")
public class OutStockController {
    @Autowired
    private OutStockService outStockService;

    //加载表格数据
    @GetMapping("/findOutStockList")
    public ResponseBean findOutStockList(@RequestParam Map<String,Object> map){
        PageVO<OutStockVO> pageVO = outStockService.findOutStockList(map);
        return ResponseBean.success(pageVO);
    }

    //放入回收站
    @PutMapping("/remove/{id}")
    public ResponseBean remove(@PathVariable Long id){
        outStockService.remove(id);
        return ResponseBean.success();
    }

    //从回收站中移出去
    @PutMapping("/back/{id}")
    public ResponseBean back(@PathVariable Long id){
        outStockService.back(id);
        return ResponseBean.success();
    }

    //审核成功
    @PutMapping("/publish/{id}")
    public ResponseBean publish(@PathVariable Long id){
        outStockService.publish(id);
        return ResponseBean.success();
    }

    //删除
    @GetMapping("/delete/{id}")
    public ResponseBean delete(@PathVariable Long id){
        outStockService.delete(id);
        return ResponseBean.success();
    }

    //添加发放记录
    @PostMapping("/addOutStock")
    public ResponseBean addOutStock(@RequestBody OutStockVO outStockVO){
        outStockService.addOutStock(outStockVO);
        return ResponseBean.success();
    }
}
